import Vue from 'vue'
import Index from './index.vue'

import homepage from './homepage.vue'
import companyProfile from './company-profile.vue'
import productCenter from './product-center.vue'
import contactUs from './contact-us.vue'
import messageBoard from './message-board.vue'
import newsDynamic from './news-dynamic.vue'
import newsDetail from './news-detail.vue'
import service from './service.vue'
import productDetail from './product-detail.vue'

import VueRouter from 'vue-router'
import VueI18n from 'vue-i18n'

import { getCookie } from 'COMMON/cookie.js'
import axios from 'axios'

Vue.use(VueRouter);
Vue.use(VueI18n);

axios.interceptors.response.use(res => {
  return res.data
})

Vue.prototype.$axios = axios;

const routes = [
  { path: '/', redirect: '/homepage' },
  { path: '/homepage', component: homepage, alias: '/' },
  { path: '/company-profile', component: companyProfile },
  { path: '/product-center/:type', component: productCenter },
  { path: '/contact-us', component: contactUs },
  { path: '/message-board', component: messageBoard },
  { path: '/news-dynamic', component: newsDynamic },
  { path: '/news-detail/:newsId', component: newsDetail },
  { path: '/service', component: service },
  { path: '/product-detail/:type/:pId', component: productDetail },
]

const i18n = new VueI18n({
  // locale: LangStorage.getLang('zh')
  locale: getCookie('PLAY_LANG','zh'),  // 语言标识
  messages: {
    'zh': require('COMMON/lang/zh'),
    'en': require('COMMON/lang/en')
  }
})

const router = new VueRouter({
  // mode: 'history',
  routes
})

window.DEBUGGING = -1 < location.href.indexOf('http://localhost')
// window.DEBUGGING = false;

new Vue({
  el: '#app',
  i18n,
  router,
  render: h => h(Index)
})
